import React, { useState } from 'react'
import { Text, Button, View, Image } from 'react-native'
import * as ImagePicker from 'expo-image-picker';

const Draft = () => {
    const [imageUrl, setImageUrl] = useState('')
    const pickImage = async ()=>{
        const result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.All,
            allowsEditing: true,
            aspect: [4, 3],
            quality: 1,
            base64: true
        })
        console.log(result)
        if (!result.canceled) {
            setImageUrl(result.assets[0].uri);
        }

    }
    return (
        <View>
            <Button 
                title="选择图片"
                onPress={pickImage}
            />
            {
                imageUrl &&
                    <Image 
                        source={{uri: imageUrl}}
                        style={{width: 200,height: 200}}
                    />
            }
        </View>
    )
}

export default Draft